home *** CD-ROM | disk | FTP | other *** search
- // Dynamic link library implementation of NeuroSolutions Axon component
-
- #include "NSDLL.h"
-
- /****************************/
- /* Transform implementation */
-
- __declspec(dllexport) BOOL performTransform(
- DLLData *instance, // Pointer to instance data
- NSFloat *data, // Pointer to the buffered data
- int length, // Length of the buffer to be transformed
- int channel // Current channal number
- )
- {
- NSFloat *corr, *firstChannel=(NSFloat*)getUserData(instance);
- BOOL displayChannel=FALSE;
- int i, j, start=0,
- channel1=getIntParameter(instance, 2, 1),
- channel2=getIntParameter(instance, 2, 2);
-
- if ((channel == channel1) || (channel == channel2)) {
- if (channel1 == channel2)
- firstChannel = data;
- if (firstChannel) {
- corr = (NSFloat*)calloc(length, sizeof(NSFloat));
- for (i=0; i<length; i++) {
- for (j=start; j<length; j++)
- corr[i] += data[j]*firstChannel[j-start];
- start++;
- }
- for (i=0; i<length; i++)
- data[i] = corr[i];
- setUserData(instance, NULL);
- displayChannel = TRUE;
- free(corr);
- } else
- setUserData(instance, data);
- }
- return displayChannel;
- }
-
- /******************************************/
- /* Management of instance data (OPTIONAL) */
-
- __declspec(dllexport) DLLData *allocTransform(
- DLLData *oldInstance, // Pointer to the last instance if reallocating
- int length, // Length of the buffer to be transformed
- int channels // Number of channels to be transformed
- )
- {
- DLLData *instance = allocDLLInstance(oldInstance);
- setParameterName(instance, 2, 1, "Chan X", FALSE);
- setIntParameter(instance, 2, 1, 0, FALSE);
- setParameterName(instance, 2, 2, "Chan Y", FALSE);
- setIntParameter(instance, 2, 2, 1, FALSE);
- return instance;
- }
-
- __declspec(dllexport) void freeTransform(DLLData *instance)
- {
- freeDLLInstance(instance);
- }
-
-